'use strict';
define(function(require,exports,module){
	var React = require('react');
	var $ = require('jquery');
	var Highcharts = require('highcharts');
	var CookieStorage = require('cookieStorage');
	var Json = require('json2');
	
	exports.get_token = function(){
		window.cookieStorage = new CookieStorage.CookieStorage();
		var qeeniao_login = cookieStorage.getItem('qeeniao_login');
		if(qeeniao_login){
	      qeeniao_login = JSON.parse(qeeniao_login);
	      return qeeniao_login.access_token;
	    }else{
	      qeeniao_login = {};
	    }
	    return;
	}
	
	exports.get_username = function(){
		window.cookieStorage = new CookieStorage.CookieStorage();
		var qeeniao_login = cookieStorage.getItem('qeeniao_login');
		if(qeeniao_login){
	      qeeniao_login = JSON.parse(qeeniao_login);
	      return qeeniao_login.username;
	    }else{
	      qeeniao_login = {};
	    }
	    return;
	}
	
	
	exports.get_query = function(){
		var token = get_token();
		var result = {};
		$.ajax({
			url:'/proxy/admin/query',
			data:{sql:sql,'access_token':token},
			type:'post',
			dataType:'json',
			success:function(o){
				return o;
				result = o;
			},
			error:function(xhr,status,err){
				console.error(sql,status,err.toString());
			}
		});
		return result;
	}
});